<template>
	<view>
		<appBar title="行业分类"></appBar>
		<uv-skeleton rows="10" :loading='loading'></uv-skeleton>
		<uv-list>
			<template v-for="item in categoryTree" :key='item.code'>
				<uv-list-item :title="item.name" clickable @click="onclick(item)"></uv-list-item>
			</template>
		</uv-list>

	</view>
</template>

<script>
	import {
		professionListApi
	} from '@/api/store.js'
	export default {
		data() {
			return {
				categoryTree: [],
				data: {
					businessType: '1',
					mainPass: '1'
				},
				loading: false
			};
		},
		onLoad() {
			this.professionListApiHandler()
		},
		computed: {
			height() {
				return uni.getSystemInfoSync().windowHeight - uni.upx2px(100);
			}
		},
		methods: {
			// 获取行业类目
			async professionListApiHandler() {
				this.loading = true
				let res = await professionListApi(this.data)
				console.log(res);
				this.categoryTree = res.data;
				this.loading = false

			},
			// 选中类目的方法
			onclick(item) {
				uni.navigateBack({
					delta: 1,
					success: () => {
						uni.$emit('selectIndustry', item.name)
					}
				});
			}
		},
	};
</script>

<style scoped lang="scss">
</style>